<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter_rb.html">
                vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="AbstractAdapter.html">
                AbstractAdapter
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The PostgreSQL adapter works both with the native C (<a
href="http://ruby.scripting.ca/postgres">ruby.scripting.ca/postgres</a>/)
and the pure Ruby (available both as gem and from <a
href="http://rubyforge.org/frs/?group_id=234&release_id=1944">rubyforge.org/frs/?group_id=234&release_id=1944</a>)
drivers.
</p>
<p>
Options:
</p>
<ul>
<li><tt>:host</tt> &#8212; Defaults to localhost

</li>
<li><tt>:port</tt> &#8212; Defaults to 5432

</li>
<li><tt>:username</tt> &#8212; Defaults to nothing

</li>
<li><tt>:password</tt> &#8212; Defaults to nothing

</li>
<li><tt>:database</tt> &#8212; The name of the database. No default, must be
provided.

</li>
<li><tt>:<a href="PostgreSQLAdapter.html#M001270">schema_search_path</a></tt>
&#8212; An optional schema search path for the connection given as a string
of comma-separated schema names. This is backward-compatible with the
:schema_order option.

</li>
<li><tt>:encoding</tt> &#8212; An optional client encoding that is used in a
SET client_encoding TO &lt;encoding&gt; call on the connection.

</li>
<li><tt>:min_messages</tt> &#8212; An optional client min messages that is used
in a SET <a href="PostgreSQLAdapter.html#M001271">client_min_messages</a>
TO &lt;min_messages&gt; call on the connection.

</li>
<li><tt>:allow_concurrency</tt> &#8212; If true, use async query methods so
Ruby threads don&#8216;t deadlock; otherwise, use blocking query methods.

</li>
</ul>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001253">active?</a>&nbsp;&nbsp;
      <a href="#M001251">adapter_name</a>&nbsp;&nbsp;
      <a href="#M001274">add_column</a>&nbsp;&nbsp;
      <a href="#M001263">begin_db_transaction</a>&nbsp;&nbsp;
      <a href="#M001275">change_column</a>&nbsp;&nbsp;
      <a href="#M001276">change_column_default</a>&nbsp;&nbsp;
      <a href="#M001277">change_column_null</a>&nbsp;&nbsp;
      <a href="#M001271">client_min_messages</a>&nbsp;&nbsp;
      <a href="#M001272">client_min_messages=</a>&nbsp;&nbsp;
      <a href="#M001268">columns</a>&nbsp;&nbsp;
      <a href="#M001264">commit_db_transaction</a>&nbsp;&nbsp;
      <a href="#M001255">disconnect!</a>&nbsp;&nbsp;
      <a href="#M001261">execute</a>&nbsp;&nbsp;
      <a href="#M001267">indexes</a>&nbsp;&nbsp;
      <a href="#M001260">insert</a>&nbsp;&nbsp;
      <a href="#M001252">new</a>&nbsp;&nbsp;
      <a href="#M001281">postgresql_version</a>&nbsp;&nbsp;
      <a href="#M001254">reconnect!</a>&nbsp;&nbsp;
      <a href="#M001279">remove_index</a>&nbsp;&nbsp;
      <a href="#M001278">rename_column</a>&nbsp;&nbsp;
      <a href="#M001273">rename_table</a>&nbsp;&nbsp;
      <a href="#M001265">rollback_db_transaction</a>&nbsp;&nbsp;
      <a href="#M001270">schema_search_path</a>&nbsp;&nbsp;
      <a href="#M001269">schema_search_path=</a>&nbsp;&nbsp;
      <a href="#M001259">select_rows</a>&nbsp;&nbsp;
      <a href="#M001256">supports_migrations?</a>&nbsp;&nbsp;
      <a href="#M001257">supports_standard_conforming_strings?</a>&nbsp;&nbsp;
      <a href="#M001258">table_alias_length</a>&nbsp;&nbsp;
      <a href="#M001266">tables</a>&nbsp;&nbsp;
      <a href="#M001280">type_to_sql</a>&nbsp;&nbsp;
      <a href="#M001262">update_sql</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001252" class="method-detail">
        <a name="M001252"></a>

        <div class="method-heading">
          <a href="#M001252" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(connection, logger, connection_parameters, config)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Initializes and connects a PostgreSQL adapter.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001252-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001252-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 233</span>
233:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">connection</span>, <span class="ruby-identifier">logger</span>, <span class="ruby-identifier">connection_parameters</span>, <span class="ruby-identifier">config</span>)
234:         <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">connection</span>, <span class="ruby-identifier">logger</span>)
235:         <span class="ruby-ivar">@connection_parameters</span>, <span class="ruby-ivar">@config</span> = <span class="ruby-identifier">connection_parameters</span>, <span class="ruby-identifier">config</span>
236: 
237:         <span class="ruby-identifier">connect</span>
238:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001253" class="method-detail">
        <a name="M001253"></a>

        <div class="method-heading">
          <a href="#M001253" class="method-signature">
          <span class="method-name">active?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Is this connection alive and ready for queries?
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001253-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001253-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 241</span>
241:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">active?</span>
242:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:status</span>)
243:           <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PGconn</span><span class="ruby-operator">::</span><span class="ruby-constant">CONNECTION_OK</span>
244:         <span class="ruby-keyword kw">else</span>
245:           <span class="ruby-comment cmt"># We're asking the driver, not ActiveRecord, so use @connection.query instead of #query</span>
246:           <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">query</span> <span class="ruby-value str">'SELECT 1'</span>
247:           <span class="ruby-keyword kw">true</span>
248:         <span class="ruby-keyword kw">end</span>
249:       <span class="ruby-comment cmt"># postgres-pr raises a NoMethodError when querying if no connection is available.</span>
250:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">PGError</span>, <span class="ruby-constant">NoMethodError</span>
251:         <span class="ruby-keyword kw">false</span>
252:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001251" class="method-detail">
        <a name="M001251"></a>

        <div class="method-heading">
          <a href="#M001251" class="method-signature">
          <span class="method-name">adapter_name</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns &#8216;PostgreSQL&#8217; as adapter name for identification
purposes.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001251-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001251-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 228</span>
228:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">adapter_name</span>
229:         <span class="ruby-value str">'PostgreSQL'</span>
230:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001274" class="method-detail">
        <a name="M001274"></a>

        <div class="method-heading">
          <a href="#M001274" class="method-signature">
          <span class="method-name">add_column</span><span class="method-args">(table_name, column_name, type, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Adds a column to a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001274-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001274-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 594</span>
594:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">options</span> = {})
595:         <span class="ruby-identifier">default</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:default</span>]
596:         <span class="ruby-identifier">notnull</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:null</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
597: 
598:         <span class="ruby-comment cmt"># Add the column.</span>
599:         <span class="ruby-identifier">execute</span>(<span class="ruby-node">&quot;ALTER TABLE #{table_name} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit])}&quot;</span>)
600: 
601:         <span class="ruby-identifier">change_column_default</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">default</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options_include_default?</span>(<span class="ruby-identifier">options</span>)
602:         <span class="ruby-identifier">change_column_null</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">default</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">notnull</span>
603:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001263" class="method-detail">
        <a name="M001263"></a>

        <div class="method-heading">
          <a href="#M001263" class="method-signature">
          <span class="method-name">begin_db_transaction</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Begins a transaction.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001263-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001263-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 422</span>
422:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">begin_db_transaction</span>
423:         <span class="ruby-identifier">execute</span> <span class="ruby-value str">&quot;BEGIN&quot;</span>
424:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001275" class="method-detail">
        <a name="M001275"></a>

        <div class="method-heading">
          <a href="#M001275" class="method-signature">
          <span class="method-name">change_column</span><span class="method-args">(table_name, column_name, type, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Changes the column of a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001275-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001275-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 606</span>
606:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">options</span> = {})
607:         <span class="ruby-keyword kw">begin</span>
608:           <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;ALTER TABLE #{table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}&quot;</span>
609:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">StatementInvalid</span>
610:           <span class="ruby-comment cmt"># This is PostgreSQL 7.x, so we have to use a more arcane way of doing it.</span>
611:           <span class="ruby-identifier">begin_db_transaction</span>
612:           <span class="ruby-identifier">tmp_column_name</span> = <span class="ruby-node">&quot;#{column_name}_ar_tmp&quot;</span>
613:           <span class="ruby-identifier">add_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">tmp_column_name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">options</span>)
614:           <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;UPDATE #{table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})&quot;</span>
615:           <span class="ruby-identifier">remove_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>)
616:           <span class="ruby-identifier">rename_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">tmp_column_name</span>, <span class="ruby-identifier">column_name</span>)
617:           <span class="ruby-identifier">commit_db_transaction</span>
618:         <span class="ruby-keyword kw">end</span>
619: 
620:         <span class="ruby-identifier">change_column_default</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:default</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options_include_default?</span>(<span class="ruby-identifier">options</span>)
621:         <span class="ruby-identifier">change_column_null</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:null</span>], <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:default</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:null</span>)
622:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001276" class="method-detail">
        <a name="M001276"></a>

        <div class="method-heading">
          <a href="#M001276" class="method-signature">
          <span class="method-name">change_column_default</span><span class="method-args">(table_name, column_name, default)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Changes the default value of a table column.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001276-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001276-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 625</span>
625:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_column_default</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">default</span>)
626:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;ALTER TABLE #{table_name} ALTER COLUMN #{quote_column_name(column_name)} SET DEFAULT #{quote(default)}&quot;</span>
627:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001277" class="method-detail">
        <a name="M001277"></a>

        <div class="method-heading">
          <a href="#M001277" class="method-signature">
          <span class="method-name">change_column_null</span><span class="method-args">(table_name, column_name, null, default = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001277-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001277-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 629</span>
629:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_column_null</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">null</span>, <span class="ruby-identifier">default</span> = <span class="ruby-keyword kw">nil</span>)
630:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">null</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>.<span class="ruby-identifier">nil?</span>
631:           <span class="ruby-identifier">execute</span>(<span class="ruby-node">&quot;UPDATE #{table_name} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL&quot;</span>)
632:         <span class="ruby-keyword kw">end</span>
633:         <span class="ruby-identifier">execute</span>(<span class="ruby-node">&quot;ALTER TABLE #{table_name} ALTER #{quote_column_name(column_name)} #{null ? 'DROP' : 'SET'} NOT NULL&quot;</span>)
634:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001271" class="method-detail">
        <a name="M001271"></a>

        <div class="method-heading">
          <a href="#M001271" class="method-signature">
          <span class="method-name">client_min_messages</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the current client message level.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001271-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001271-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 510</span>
510:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">client_min_messages</span>
511:         <span class="ruby-identifier">query</span>(<span class="ruby-value str">'SHOW client_min_messages'</span>)[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>]
512:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001272" class="method-detail">
        <a name="M001272"></a>

        <div class="method-heading">
          <a href="#M001272" class="method-signature">
          <span class="method-name">client_min_messages=</span><span class="method-args">(level)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Set the client message level.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001272-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001272-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 515</span>
515:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">client_min_messages=</span>(<span class="ruby-identifier">level</span>)
516:         <span class="ruby-identifier">execute</span>(<span class="ruby-node">&quot;SET client_min_messages TO '#{level}'&quot;</span>)
517:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001268" class="method-detail">
        <a name="M001268"></a>

        <div class="method-heading">
          <a href="#M001268" class="method-signature">
          <span class="method-name">columns</span><span class="method-args">(table_name, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the list of all column definitions for a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001268-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001268-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 485</span>
485:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">columns</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
486:         <span class="ruby-comment cmt"># Limit, precision, and scale are all handled by the superclass.</span>
487:         <span class="ruby-identifier">column_definitions</span>(<span class="ruby-identifier">table_name</span>).<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">default</span>, <span class="ruby-identifier">notnull</span><span class="ruby-operator">|</span>
488:           <span class="ruby-constant">PostgreSQLColumn</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">default</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">notnull</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'f'</span>)
489:         <span class="ruby-keyword kw">end</span>
490:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001264" class="method-detail">
        <a name="M001264"></a>

        <div class="method-heading">
          <a href="#M001264" class="method-signature">
          <span class="method-name">commit_db_transaction</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Commits a transaction.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001264-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001264-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 427</span>
427:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commit_db_transaction</span>
428:         <span class="ruby-identifier">execute</span> <span class="ruby-value str">&quot;COMMIT&quot;</span>
429:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001255" class="method-detail">
        <a name="M001255"></a>

        <div class="method-heading">
          <a href="#M001255" class="method-signature">
          <span class="method-name">disconnect!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Close the connection.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001255-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001255-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 266</span>
266:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">disconnect!</span>
267:         <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
268:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001261" class="method-detail">
        <a name="M001261"></a>

        <div class="method-heading">
          <a href="#M001261" class="method-signature">
          <span class="method-name">execute</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes an SQL statement, returning a PGresult object on success or
raising a PGError exception otherwise.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001261-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001261-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 406</span>
406:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
407:         <span class="ruby-identifier">log</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>) <span class="ruby-keyword kw">do</span>
408:           <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@async</span>
409:             <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">async_exec</span>(<span class="ruby-identifier">sql</span>)
410:           <span class="ruby-keyword kw">else</span>
411:             <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">exec</span>(<span class="ruby-identifier">sql</span>)
412:           <span class="ruby-keyword kw">end</span>
413:         <span class="ruby-keyword kw">end</span>
414:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001267" class="method-detail">
        <a name="M001267"></a>

        <div class="method-heading">
          <a href="#M001267" class="method-signature">
          <span class="method-name">indexes</span><span class="method-args">(table_name, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the list of all <a
href="PostgreSQLAdapter.html#M001267">indexes</a> for a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001267-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001267-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 450</span>
450:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">indexes</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
451:         <span class="ruby-identifier">result</span> = <span class="ruby-identifier">query</span>(<span class="ruby-value str">&quot;SELECT i.relname, d.indisunique, a.attname\nFROM pg_class t, pg_class i, pg_index d, pg_attribute a\nWHERE i.relkind = 'i'\nAND d.indexrelid = i.oid\nAND d.indisprimary = 'f'\nAND t.oid = d.indrelid\nAND t.relname = '\#{table_name}'\nAND a.attrelid = t.oid\nAND ( d.indkey[0]=a.attnum OR d.indkey[1]=a.attnum\nOR d.indkey[2]=a.attnum OR d.indkey[3]=a.attnum\nOR d.indkey[4]=a.attnum OR d.indkey[5]=a.attnum\nOR d.indkey[6]=a.attnum OR d.indkey[7]=a.attnum\nOR d.indkey[8]=a.attnum OR d.indkey[9]=a.attnum )\nORDER BY i.relname\n&quot;</span>, <span class="ruby-identifier">name</span>)
452: 
453:         <span class="ruby-identifier">current_index</span> = <span class="ruby-keyword kw">nil</span>
454:         <span class="ruby-identifier">indexes</span> = []
455: 
456:         <span class="ruby-identifier">result</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
457:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current_index</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>]
458:             <span class="ruby-identifier">indexes</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">IndexDefinition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">row</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;t&quot;</span>, [])
459:             <span class="ruby-identifier">current_index</span> = <span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>]
460:           <span class="ruby-keyword kw">end</span>
461: 
462:           <span class="ruby-identifier">indexes</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">columns</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">row</span>[<span class="ruby-value">2</span>]
463:         <span class="ruby-keyword kw">end</span>
464: 
465:         <span class="ruby-identifier">indexes</span>
466:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001260" class="method-detail">
        <a name="M001260"></a>

        <div class="method-heading">
          <a href="#M001260" class="method-signature">
          <span class="method-name">insert</span><span class="method-args">(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes an INSERT query and returns the <a
href="PostgreSQLAdapter.html#M001252">new</a> record&#8216;s ID
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001260-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001260-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 388</span>
388:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">pk</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">id_value</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">sequence_name</span> = <span class="ruby-keyword kw">nil</span>)
389:         <span class="ruby-identifier">table</span> = <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot; &quot;</span>, <span class="ruby-value">4</span>)[<span class="ruby-value">2</span>]
390:         <span class="ruby-keyword kw">super</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">last_insert_id</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">sequence_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default_sequence_name</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">pk</span>))
391:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001254" class="method-detail">
        <a name="M001254"></a>

        <div class="method-heading">
          <a href="#M001254" class="method-signature">
          <span class="method-name">reconnect!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Close then reopen the connection.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001254-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001254-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 255</span>
255:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reconnect!</span>
256:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:reset</span>)
257:           <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">reset</span>
258:           <span class="ruby-identifier">configure_connection</span>
259:         <span class="ruby-keyword kw">else</span>
260:           <span class="ruby-identifier">disconnect!</span>
261:           <span class="ruby-identifier">connect</span>
262:         <span class="ruby-keyword kw">end</span>
263:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001279" class="method-detail">
        <a name="M001279"></a>

        <div class="method-heading">
          <a href="#M001279" class="method-signature">
          <span class="method-name">remove_index</span><span class="method-args">(table_name, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Drops an index from a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001279-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001279-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 642</span>
642:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_index</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">options</span> = {})
643:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;DROP INDEX #{index_name(table_name, options)}&quot;</span>
644:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001278" class="method-detail">
        <a name="M001278"></a>

        <div class="method-heading">
          <a href="#M001278" class="method-signature">
          <span class="method-name">rename_column</span><span class="method-args">(table_name, column_name, new_column_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Renames a column in a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001278-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001278-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 637</span>
637:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rename_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">new_column_name</span>)
638:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;ALTER TABLE #{table_name} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}&quot;</span>
639:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001273" class="method-detail">
        <a name="M001273"></a>

        <div class="method-heading">
          <a href="#M001273" class="method-signature">
          <span class="method-name">rename_table</span><span class="method-args">(name, new_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Renames a table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001273-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001273-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 589</span>
589:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rename_table</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">new_name</span>)
590:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;ALTER TABLE #{name} RENAME TO #{new_name}&quot;</span>
591:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001265" class="method-detail">
        <a name="M001265"></a>

        <div class="method-heading">
          <a href="#M001265" class="method-signature">
          <span class="method-name">rollback_db_transaction</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Aborts a transaction.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001265-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001265-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 432</span>
432:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rollback_db_transaction</span>
433:         <span class="ruby-identifier">execute</span> <span class="ruby-value str">&quot;ROLLBACK&quot;</span>
434:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001270" class="method-detail">
        <a name="M001270"></a>

        <div class="method-heading">
          <a href="#M001270" class="method-signature">
          <span class="method-name">schema_search_path</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the active schema search path.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001270-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001270-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 505</span>
505:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">schema_search_path</span>
506:         <span class="ruby-ivar">@schema_search_path</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">query</span>(<span class="ruby-value str">'SHOW search_path'</span>)[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>]
507:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001269" class="method-detail">
        <a name="M001269"></a>

        <div class="method-heading">
          <a href="#M001269" class="method-signature">
          <span class="method-name">schema_search_path=</span><span class="method-args">(schema_csv)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets the schema search path to a string of comma-separated schema names.
Names beginning with $ have to be quoted (e.g. $user =&gt;
&#8217;$user&#8217;). See: <a
href="http://www.postgresql.org/docs/current/static/ddl-schemas.html">www.postgresql.org/docs/current/static/ddl-schemas.html</a>
</p>
<p>
This should be not be called manually but set in database.yml.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001269-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001269-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 497</span>
497:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">schema_search_path=</span>(<span class="ruby-identifier">schema_csv</span>)
498:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">schema_csv</span>
499:           <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;SET search_path TO #{schema_csv}&quot;</span>
500:           <span class="ruby-ivar">@schema_search_path</span> = <span class="ruby-identifier">schema_csv</span>
501:         <span class="ruby-keyword kw">end</span>
502:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001259" class="method-detail">
        <a name="M001259"></a>

        <div class="method-heading">
          <a href="#M001259" class="method-signature">
          <span class="method-name">select_rows</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes a SELECT query and returns an array of rows. Each row is an array
of field values.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001259-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001259-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 383</span>
383:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_rows</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
384:         <span class="ruby-identifier">select_raw</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>).<span class="ruby-identifier">last</span>
385:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001256" class="method-detail">
        <a name="M001256"></a>

        <div class="method-heading">
          <a href="#M001256" class="method-signature">
          <span class="method-name">supports_migrations?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Does PostgreSQL support migrations?
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001256-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001256-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 288</span>
288:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">supports_migrations?</span>
289:         <span class="ruby-keyword kw">true</span>
290:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001257" class="method-detail">
        <a name="M001257"></a>

        <div class="method-heading">
          <a href="#M001257" class="method-signature">
          <span class="method-name">supports_standard_conforming_strings?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Does PostgreSQL support standard conforming strings?
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001257-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001257-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 293</span>
293:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">supports_standard_conforming_strings?</span>
294:         <span class="ruby-comment cmt"># Temporarily set the client message level above error to prevent unintentional</span>
295:         <span class="ruby-comment cmt"># error messages in the logs when working on a PostgreSQL database server that</span>
296:         <span class="ruby-comment cmt"># does not support standard conforming strings.</span>
297:         <span class="ruby-identifier">client_min_messages_old</span> = <span class="ruby-identifier">client_min_messages</span>
298:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">client_min_messages</span> = <span class="ruby-value str">'panic'</span>
299: 
300:         <span class="ruby-comment cmt"># postgres-pr does not raise an exception when client_min_messages is set higher</span>
301:         <span class="ruby-comment cmt"># than error and &quot;SHOW standard_conforming_strings&quot; fails, but returns an empty</span>
302:         <span class="ruby-comment cmt"># PGresult instead.</span>
303:         <span class="ruby-identifier">has_support</span> = <span class="ruby-identifier">execute</span>(<span class="ruby-value str">'SHOW standard_conforming_strings'</span>)[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>] <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">false</span>
304:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">client_min_messages</span> = <span class="ruby-identifier">client_min_messages_old</span>
305:         <span class="ruby-identifier">has_support</span>
306:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001258" class="method-detail">
        <a name="M001258"></a>

        <div class="method-heading">
          <a href="#M001258" class="method-signature">
          <span class="method-name">table_alias_length</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the configured supported identifier length supported by PostgreSQL,
or report the default of 63 on PostgreSQL 7.x.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001258-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001258-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 310</span>
310:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">table_alias_length</span>
311:         <span class="ruby-ivar">@table_alias_length</span> <span class="ruby-operator">||=</span> (<span class="ruby-identifier">postgresql_version</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">80000</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">query</span>(<span class="ruby-value str">'SHOW max_identifier_length'</span>)[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">:</span> <span class="ruby-value">63</span>)
312:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001266" class="method-detail">
        <a name="M001266"></a>

        <div class="method-heading">
          <a href="#M001266" class="method-signature">
          <span class="method-name">tables</span><span class="method-args">(name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the list of all <a href="PostgreSQLAdapter.html#M001266">tables</a>
in the schema search path or a specified schema.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001266-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001266-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 439</span>
439:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tables</span>(<span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
440:         <span class="ruby-identifier">schemas</span> = <span class="ruby-identifier">schema_search_path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">quote</span>(<span class="ruby-identifier">p</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>)
441:         <span class="ruby-identifier">query</span>(<span class="ruby-value str">&quot;SELECT tablename\nFROM pg_tables\nWHERE schemaname IN (\#{schemas})\n&quot;</span>, <span class="ruby-identifier">name</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span> <span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>] }
442:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001280" class="method-detail">
        <a name="M001280"></a>

        <div class="method-heading">
          <a href="#M001280" class="method-signature">
          <span class="method-name">type_to_sql</span><span class="method-args">(type, limit = nil, precision = nil, scale = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Maps logical <a href="../../Rails.html">Rails</a> types to
PostgreSQL-specific data types.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001280-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001280-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 647</span>
647:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type_to_sql</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">limit</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">precision</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">scale</span> = <span class="ruby-keyword kw">nil</span>)
648:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">super</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'integer'</span>
649: 
650:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">limit</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">limit</span> <span class="ruby-operator">==</span> <span class="ruby-value">4</span>
651:           <span class="ruby-value str">'integer'</span>
652:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">limit</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">4</span>
653:           <span class="ruby-value str">'smallint'</span>
654:         <span class="ruby-keyword kw">else</span>
655:           <span class="ruby-value str">'bigint'</span>
656:         <span class="ruby-keyword kw">end</span>
657:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001262" class="method-detail">
        <a name="M001262"></a>

        <div class="method-heading">
          <a href="#M001262" class="method-signature">
          <span class="method-name">update_sql</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes an UPDATE query and returns the number of affected tuples.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001262-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001262-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 417</span>
417:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
418:         <span class="ruby-keyword kw">super</span>.<span class="ruby-identifier">cmdtuples</span>
419:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M001281" class="method-detail">
        <a name="M001281"></a>

        <div class="method-heading">
          <a href="#M001281" class="method-signature">
          <span class="method-name">postgresql_version</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the version of the connected PostgreSQL version.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001281-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001281-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 696</span>
696:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">postgresql_version</span>
697:           <span class="ruby-ivar">@postgresql_version</span> <span class="ruby-operator">||=</span>
698:             <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:server_version</span>)
699:               <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">server_version</span>
700:             <span class="ruby-keyword kw">else</span>
701:               <span class="ruby-comment cmt"># Mimic PGconn.server_version behavior</span>
702:               <span class="ruby-keyword kw">begin</span>
703:                 <span class="ruby-identifier">query</span>(<span class="ruby-value str">'SELECT version()'</span>)[<span class="ruby-value">0</span>][<span class="ruby-value">0</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/PostgreSQL (\d+)\.(\d+)\.(\d+)/</span>
704:                 (<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">*</span> <span class="ruby-value">10000</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">$2</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">*</span> <span class="ruby-value">100</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">$3</span>.<span class="ruby-identifier">to_i</span>
705:               <span class="ruby-keyword kw">rescue</span>
706:                 <span class="ruby-value">0</span>
707:               <span class="ruby-keyword kw">end</span>
708:             <span class="ruby-keyword kw">end</span>
709:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>